// (c) Copyright 2013 Mike Riedel.
// This source is subject to the Microsoft Public License (Ms-PL).
// All other rights reserved.

using System;

namespace FreshMeat.ErrorHandlingBlock
{
   /// <summary>
   /// Describes how a category of errors should be handled.
   /// </summary>
   public interface IErrorPolicy
   {
      /// <summary>
      /// Determines whether the policy applies to an error.
      /// </summary>
      /// <param name="error">The error.</param>
      /// <returns>True if this policy applies to the error.</returns>
      bool IsApplicable(Exception error);

      /// <summary>
      /// Applies the policy to an error.
      /// </summary>
      /// <param name="error">The error.</param>
      /// <param name="attempts">How many times the error has occurred.</param>
      /// <returns>The result of applying the policy, which includes a diagnosis of the problem and whether to retry.</returns>
      ErrorPolicyResult Apply(Exception error, int attempts);
   }
}